<!-- 更多资讯 -->
<template>
	<div class="mui-scroll-wrapper" id="pullrefresh">
		<div class="mui-scroll">
		  <div class="find">
		    <div class="info-tab">
          <ul  v-for="item in findListData">
            <li @tap="goCarInfoDetail(item)">
		          <find-item :data="item"></find-item>
            </li>
          </ul>
		    </div>  
		  </div>
		</div>
	</div>
</template>

<script>
import FindItem from '@/components/base/find-item/find-item'
import importUrl from '../../../../mock/find-list'
import mui from 'static/js/mui'
//import {getNews} from "@/api/carInfo"
import {getNewsPage} from '@/nodeApi/config'
import utils from '@/utils/utils'

export default {
  components: {
    FindItem
  },
  data () {
    return {
      findListData: [],
      flag:false,
      thsobj:{},
      pageObj:{
          pageNow: 0,
          pageSize: 5
      }
    }
  },
  props: {},
  watch: {},
  methods: {
    /* _initFindListData () {
    	// //console.log(importUrl)
    	if(process.env.NODE_ENV == 'production'){
    		this.findListData = importUrl.data
    		return;
    	}    	    	
      axios.get('/api/findList').then(res => {
        if (res.data.code === 0) {
          this.findListData = res.data.data.data
        }
      }).catch(err => {
        //console.log(err)
      })
    }, */
    goCarInfoDetail(v) {
      this.$router.push({
          name: "carInfoDetail",
          params: {
              news:v
          }
      })
    },
    handelGetNews() {
      this.pageObj.pageNow++  
      getNewsPage(this.pageObj).then(res =>{
        this.findListData=this.findListData.concat(res.data.news)
        try{
          //console.log(this.pageObj.pageNow)
          //console.log(res.data.page.totalPageCount )
          if(res.data.page.totalPageCount <= this.pageObj.pageNow){
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
          }
          else{
            // 如果有更多数据，则继续
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
          }
        }catch(e) {
          //console.log('我在231行')
        }
      })
    },
    formatTime(time) {
      try{
          return utils.time.formatDatetwo(time)
          }catch(e){
          '逻辑错误，期货拼单历史返回问题'
      }
    },
    /* mui刷新每次切换路由记得申明这个，别问为什么，百度 */
    refresh() {
      for(var i = mui.hooks.inits.length-1,item;i>=0;i--){
        item=mui.hooks.inits[i];
        if(item.name=="pullrefresh"){
            item.repeat=true;
        }
      }
    }
  },
  filters: {},
  computed: {},
  created () {
    /* mui刷新每次切换路由记得申明这个，别问为什么，百度 */
    this.refresh()
    /*  this._initFindListData() */
    this.handelGetNews()
  },
  mounted () {
    let that = this
    mui.init({
        keyEventBind: {
        backbutton: true  //关闭back按键监听
        },
        pullRefresh : {
          container:"#pullrefresh",//待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
          up : {
              height:50,// 可选.默认50.触发上拉加载拖动距离
              auto:false,// 可选,默认false.自动上拉加载一次
              contentrefresh : "正在加载...",// 可选，正在加载状态时，上拉加载控件上显示的标题内容
              contentnomore:'没有更多数据了',// 可选，请求完毕若没有更多数据时显示的提醒内容；
              callback : function() {
                // 加载更多的内容
                ////console.log("触发下来加载")
                that.handelGetNews()
              } //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
          }
        }
    })
    mui.back = function () {
        history.go(-1)
    }
  	//初始滚动
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005, //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			indicators: false //是否显示滚动条
		});  	
  },
  destroyed () {}
}
</script>

<style lang="scss" scoped>
@import '~@/assets/scss/const.scss';
@import '~@/assets/scss/mixin.scss';
.info-tab ul li{
  border-bottom:1px solid #e9e9e9;
}
</style>
